package com.ravi.common.utils.md5;

import com.ravi.common.constant.SystemConstant;
import org.apache.tomcat.util.codec.binary.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Utils {
	public static String getMD5Str(String strVal) throws NoSuchAlgorithmException {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		return Base64.encodeBase64String(md5.digest((strVal+ SystemConstant.SALT).getBytes()));
	}

	public static void main(String[] args) {
		String md5 = null;
		try {
			md5 = getMD5Str("111222"); // cRlYZSiH6k4TDxeASdsS0Q==24
		}catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(md5 + md5.length());
	}
}
